<template>
    <div>
        <h1>会员等级</h1>
        <table class="">
            <tr>
                <td>会员等级:</td>
                <td>
                    <input type="text" v-model="data.dname">
                </td>
            </tr>
            <tr>
                <td>分配权益：</td>
                <td>
                    <span v-for="d in ts">
                        <input type="checkbox" v-model="dds"  :value="d" >{{d}}
                    </span>
                </td>
            </tr>
            <tr>
                <td></td>
                <td>
                    <input type="button" value="添加" @click="dengadd" class="btn btn-success">
                </td>
            </tr>
        </table>
    </div>
</template>
<script setup lang="ts">
import { ref,onMounted } from 'vue';
import axios from 'axios';
import { useRouter,useRoute } from 'vue-router';
import { useStore } from '@/stores/info';
const userst=useStore();

const router=useRouter();
const route=useRoute();
const dds=ref([]);
const ts=ref(["免费停车","打折优惠","吃饭免费","餐饮折扣","住宿折扣"]);


const data=ref({
    
  "lId": 0,
  "dname": "",
  "quanCount": 0,
  "qname": "",
  "state": true

})

const dengadd=()=>{

    data.value.quanCount=dds.value.length;
    data.value.qname=dds.value.toString();

    axios.post("https://localhost:7237/api/Deng/DengAdd",data.value).then(res=>{
        if(res.data>0){
            alert('添加成功');
            router.push({path:"/levershow"})
        }
        else{
            alert('添加失败');
        }
    })
}
</script>

<style scoped>

</style>